#include<stdio.h>
#include<string.h>
int main()
{
	int n = 0;
	while (~scanf("%d", &n))
	{
		int i = 0;
		for (i = 0; i<n; i++)
		{
			char arr[101] = { 0 };
			scanf("%s", arr);
			if (strlen(arr)<8)
			{
				printf("NO\n");
				continue;
			}
			if (arr[0] >= '1'&&arr[0] <= '9')
			{
				printf("NO\n");
				continue;
			}
			char *prt = arr;
			int a = 0;
			int b = 0;
			int c = 0;
			int d = 0;
			while (*prt != '\0')
			{
				if (*prt >= 'a'&&*prt <= 'z')
					a++;
				else if (*prt >= 'A'&&*prt <= 'Z')
					b++;
				else if (*prt >= '1'&&*prt <= '9')
					c++;
				else
					d++;
				prt++;
			}
			if (d>0)
			{
				printf("NO\n");
				continue;
			}
			if ((a>0) + (b>0) + (c>0)<2)
			{
				printf("NO\n");
				continue;
			}
			printf("YES\n");
		}
	}
	return 0;
}